#pragma once
#include <boost/array.hpp>

namespace ja2{ namespace sgp
{
	//! Random manager.
	class RandomManager : boost::noncopyable
	{
		// Constants
	private:
		//! Random max.
		static std::int_least16_t const RANDOM_MAX = RAND_MAX;

		// Operations
	public:
		//! Get random number.
		std::uint32_t get_random_number(std::uint32_t MaxNumber) const;
		//! Get chance.
		bool chance(std::uint_least32_t MaxNumber) const;
	protected:
		//! Get real random number.
		std::uint32_t get_real_random(std::uint32_t MaxNumber) const;
	private:
		//! Implementation.
		virtual std::uint32_t do_get_random_number(std::uint32_t MaxNumber) const;
	};

	//! Multiplayer random manager.
	class MultiplayerRandomManager : public RandomManager
	{
		// Constants
	private:
		//IMPORTANT: Changing this define will invalidate the JA2 save.	If this is necessary, please ifdef your own value.
		static std::uint_least16_t const MAX_PREGENERATED_NUMS = 256;
		//! Current index.
		mutable std::uint_least16_t m_Index;

	private:
		//! Pre-random numbers.
		boost::array<std::uint32_t, MAX_PREGENERATED_NUMS> m_PreRandomNumbers;

		// Operations
	private:
		//! Implementation.
		virtual std::uint32_t do_get_random_number(std::uint32_t MaxNumber) const;

		// Construction/Destruction
	public:
		MultiplayerRandomManager();
	};
} /*sgp*/} /*ja2*/
